<?php

use App\Http\Middleware\Cros;
use App\Http\Middleware\LastLogin;
use App\Http\Middleware\CheckToken;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
//小说有关
Route::middleware([Cros::class])->group(function(){
    Route::get('novel/list', 'Api\NovelController@getNovelList');
    Route::get('chapter/list/{novel_id}/{page}/{rows}', 'Api\NovelController@getChapterList');
    Route::get('content/{chapter_id}', 'Api\NovelController@getContent');

});
Route::middleware([Cros::class,LastLogin::class, CheckToken::class])
    ->prefix('novel')->group(function(){
    Route::post('add/bookmark/{chapter_id}/{novel_id}', 'Api\NovelController@addBookmark');
    Route::get('bookmark', 'Api\NovelController@getBookmark');
    Route::post('add/sight', 'Api\NovelController@addSight');
    Route::get('sight/{content_id}', 'Api\NovelController@getSightByContent');
    Route::get('novel/search', 'Api\NovelController@search');

    });
//用户有关
Route::middleware([Cros::class])
    ->prefix('user')->group(function(){
    Route::post('register','Api\UserController@register');
    Route::post('login','Api\UserController@login');
    Route::get('send/mail/code','Api\UserController@getCode');
});
Route::middleware([Cros::class,LastLogin::class, CheckToken::class])
    ->prefix('user')->group(function(){
    Route::post('modify','Api\UserController@modify');
    Route::get('info','Api\UserController@userInfo');
});
Route::any('test','TestController@index');
